﻿namespace MyTRCP.Common.Models
{
    public class VolumeInfo : BitWalkableObj
    {
        public byte NowVolume { get; set; }
        public byte MaxVolume { get; set; }
        public VolumeInfo(byte[] data) : base(data) { }
        public override BitWalker WriteToBitWalker(BitWalker bw)
        {
            return bw.WriteBits(NowVolume, 8).WriteBits(MaxVolume, 8);
        }

        public override BitWalker ReadFromBitWalker(BitWalker bw)
        {
            if (bw.ByteLen < 2)
                throw new ArgumentException("字节数组长度过小（2）", nameof(bw));
            NowVolume = (byte)bw.ReadBits(8);
            MaxVolume = (byte)bw.ReadBits(8);
            return bw;
        }
    }
}